import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import Editor from "./Editor"
import blockConfig from './block.json';
// import './editor/editor.css';
// import { transformToCBP, transformFromCBP } from './editor/transforms';
import { ContainerRender } from './front/render';
// import { blockIcon } from './icons';
import { Attributes } from './types';

registerBlockType<Attributes>(blockConfig.name, {
    ...blockConfig,

    // Types seem to be mismatched if importing these from block.json
    attributes: {
        title: { type: 'string', default: '一个容器' },
        theme: { type: 'string', default: 'Success' },
        children: { type: 'object', default: [] }
    },
    // Need to add these here to avoid TS type errors
    supports: {
        html: false,
        align: ['wide', 'full'],
    },
    title: __('Container Pro', 'container-pro'),
    edit: ({ attributes, setAttributes }) => (
        <Editor attributes={attributes} setAttributes={setAttributes} />
    ),
    save: ({ attributes }) => <ContainerRender attributes={attributes} />,
    // transforms: {
    //     from: [
    //         {
    //             type: 'block',
    //             blocks: ['core/code', 'syntaxhighlighter/code'],
    //             transform: transformToCBP,
    //         },
    //     ],
    //     to: [
    //         {
    //             type: 'block',
    //             blocks: ['core/code'],
    //             transform: transformFromCBP,
    //         },
    //     ],
    // },
});
